

TOOLCHAIN_PREFIX = D:/SysGCC/risc-v/bin/riscv64-unknown-elf-
OUT_DIR = Debug
INC_SRC = -I./inc
# INC_SRC = -I./lib


# --------------------------- 指定要编译的用户工程 ----------------------------
# include user/01_timer/01_timer.mk     # serv 软件多定时器
# include user/02_spi/02_spi.mk           # serv 软件spi
include user/03_i2c/conf.mk             # serv 软件I2C
# include user/04_uart/conf.mk             # serv 软件 串口 发送 
# include user/05_28byj48/conf.mk            # serv 步进电机28byj48
# include user/06_pid/conf.mk             # 慢速PID   ms级别
# include user/07_PWM/conf.mk             # 低频PWM   Hz级别 
# include user/08_LedStatus/conf.mk        #Led 状态灯控制   
# include user/09_usdelay/conf.mk    
# include user/10_eeprom/conf.mk            # EEPROM 读写 
# include user/11_LM75_temp/conf.mk           # LM75 温度传感器 
# include user/12_AHT10/conf.mk              # AHT10 温度检测

# include user/basedemo/conf.mk             # 多模块调用
# ---------------------------------------------------------------------------


all:clean firmware.hex


firmware.hex: firmware.lds
	@mkdir -p $(OUT_DIR)
	@$(TOOLCHAIN_PREFIX)gcc -O1  -nostdlib -march=rv32i -mabi=ilp32 -o $(OUT_DIR)/firmware.elf src/firmware.S $(MAIN_SRC) --std=gnu99 -Wl,-Bstatic,-T,firmware.lds,-Map,$(OUT_DIR)/firmware.map,--strip-debug -lgcc $(INC_SRC) 
	@$(TOOLCHAIN_PREFIX)objcopy -O binary $(OUT_DIR)/firmware.elf $(OUT_DIR)/firmware.bin
	@$(TOOLCHAIN_PREFIX)size $(OUT_DIR)/firmware.elf
	@python3 makehex.py $(OUT_DIR)/firmware.bin 8192 > $(OUT_DIR)/firmware.hex


clean:
	@rm -rf $(OUT_DIR)

